﻿namespace HiMap.MapControls
{
    using HiMap.Style;
    using System;
    using System.ComponentModel;
    using System.Drawing;
    using System.Windows.Forms;

    internal class FrmStyle : Form
    {
        private IContainer components;
        private MainMenu mainMenu1;
        private MenuItem menuItem1;
        private MenuItem menuItem2;
        private IStyle sty;
        private StyleControl StyleCol;

        public FrmStyle()
        {
            this.InitializeComponent();
            this.getText();
        }

        public FrmStyle(IStyle style)
        {
            this.InitializeComponent();
            this.LoadStyle(style);
            this.getText();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void getText()
        {
            this.menuItem1.Text = Setup.GetInfo("FrmStylemenuItem1");
            this.menuItem2.Text = Setup.GetInfo("FrmStylemenuItem2");
            this.Text = Setup.GetInfo("FrmStyleCaption");
        }

        private void InitializeComponent()
        {
            this.mainMenu1 = new MainMenu();
            this.menuItem1 = new MenuItem();
            this.menuItem2 = new MenuItem();
            this.StyleCol = new StyleControl();
            base.SuspendLayout();
            this.mainMenu1.MenuItems.Add(this.menuItem1);
            this.mainMenu1.MenuItems.Add(this.menuItem2);
            this.menuItem1.Text = "";
            this.menuItem1.Click += new EventHandler(this.menuItem1_Click);
            this.menuItem2.Text = "";
            this.menuItem2.Click += new EventHandler(this.menuItem2_Click);
            this.StyleCol.Dock = DockStyle.Fill;
            this.StyleCol.Location = new Point(0, 0);
            this.StyleCol.Name = "StyleCol";
            this.StyleCol.Size = new Size(240, 0x10c);
            this.StyleCol.TabIndex = 0;
            base.AutoScaleDimensions = new SizeF(96f, 96f);
            base.AutoScaleMode = AutoScaleMode.Dpi;
            this.AutoScroll = true;
            base.ClientSize = new Size(240, 0x10c);
            base.Controls.Add(this.StyleCol);
            base.Menu = this.mainMenu1;
            base.Name = "FrmStyle";
            this.Text = "Setup Style";
            base.ResumeLayout(false);
        }

        public void LoadStyle(IStyle style)
        {
            this.StyleCol.LoadDefault(style);
        }

        private void menuItem1_Click(object sender, EventArgs e)
        {
            this.sty = this.StyleCol.GetStyle;
            base.Close();
        }

        private void menuItem2_Click(object sender, EventArgs e)
        {
            this.sty = null;
            base.Close();
        }

        public IStyle GetStyle
        {
            get
            {
                return this.sty;
            }
        }
    }
}

